<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="stylesheet" href="view/css/bootstrap.css">
    <script src="view/js/bootstrap.js"></script>
    <script src="view/js/jquery.js"></script>
    <title>video_state</title>
</head>

<body>
    <div class="container">
        <h2>视频时长统计; 时长统计暂时只只支持MP4后缀; 分组平均时长不计算未分组人员</h2>

        <div class="input-group">
            <span class="input-group-addon" id="basic-addon1">视频目录地址</span>
            <input type="text" class="form-control" id="video_path" placeholder="视频目录地址" aria-describedby="basic-addon1" >
        </div>

        <div class="input-group">
            <span class="input-group-addon" id="basic-addon1">视频筛选条件</span>
            <input type="text" class="form-control" id="video_where" placeholder="视频筛选条件" aria-describedby="basic-addon1" >

        </div>
        <div class="input-group">
            <span class="input-group-addon" id="basic-addon1">分组计算时长</span>
            <input type="text" class="form-control" id="video_group" placeholder="分组计算-用 , 分割" aria-describedby="basic-addon1">
        </div>

        <div class="input-group">
            <span class="input-group-addon" id="basic-addon1">视频后缀类型</span>
            <input type="text" class="form-control" id="video_suffix_type" value=".mp4,.wmv" placeholder="视频后缀类型: .mp4,.wmv" aria-describedby="basic-addon1">
        </div>
        <input class="btn btn-info form-control" id="video_state" type="button" value="计算">
    </div>

    <div class="container">
        <h2>计算结果</h2>
        <table class="table table-striped" id="video_ret">
            <thead>
                <tr>
                    <th>#</th>
                    <th>视频描述</th>
                    <th>视频总时长</th>
                    <th>视频数量</th>
                </tr>
            </thead>
            <tbody id="video_rets">

            </tbody>
        </table>
    </div>
</body>
<script>
    $("#video_state").click(function() {
        console.log( $("#video_group").val())
            $.ajax({
                type: "post",
                url: "video_state",
                dataType: "json",
                data: JSON.stringify({
                    path: $("#video_path").val(),
                    where: $("#video_where").val(),
                    group: $("#video_group").val(),
                    suffix_type: $("#video_suffix_type").val()
                }),
                success: function(ret) {
                    if (ret.code != 200) {
                        alert(ret.msg)
                    }
                    $("#video_rets").empty();
                    $.each(ret.data, function(index, value) {
                        console.log(value)
                        $("#video_rets").append(`<tr>
                            <th>${index}</th>
                            <th>${value.Desc}</th>
                            <th>${value.Time}</th>
                            <th>${value.Num}</th>
                        </tr>`)
                    })
                }
            })
        })
        // $(function () {

    // })
</script>

</html>